package com.greensecurity.sim.service.impl;

import com.greensecurity.sim.entity.GreenLand;
import com.greensecurity.sim.repository.GreenLandRepository;
import com.greensecurity.sim.service.GreenLandService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

@Service
public class GreenLandServiceImpl implements GreenLandService {
    @Resource
    private GreenLandRepository greenLandRepository;

    @Override
    public Optional<GreenLand> findGreenLandById(Long id) {
        return greenLandRepository.findById(id);
    }

    @Override
    public String saveGreenLand(GreenLand greenLand) {
        greenLandRepository.save(greenLand);
        return "保存成功";
    }

    @Override
    public String delGreenLand(Long id) {
        greenLandRepository.deleteGreendKey(String.valueOf(id));
        greenLandRepository.deleteById(id);
        return "删除成功";
    }

    @Override
    public List<GreenLand> findGreenLandAll() {
        return greenLandRepository.findAll();
    }

    @Override
    public List<GreenLand> findGreenLandLimit() {
        return greenLandRepository.findGreenLandLimit();
    }


}
